Fix display of meta bindings in which-key-show-keymap
authorJustin Burkett <justin@burkett.cc>
Wed, 28 Feb 2018 16:20:20 +0000 (11:20 -0500)
committerJustin Burkett <justin@burkett.cc>
Wed, 28 Feb 2018 16:20:20 +0000 (11:20 -0500)
which-key.el

index a6a4c3ebc895433f3d1228d78bff4b1e75fcf67a..c76b6538bd9692842a3c05990e912b8bc9b0ecab 100644 (file)
@@ -1687,20 +1687,27 @@ ones. PREFIX is for internal use and should not be used."
      (lambda (ev def)
        (let* ((key (append prefix (list ev)))
               (key-desc (key-description key)))
-         (unless (string-match-p which-key--ignore-keys-regexp key-desc)
-           (if (and all (keymapp def))
+         (unless (or (string-match-p which-key--ignore-keys-regexp key-desc)
+                     (eq ev 'menu-bar))
+           (if (and (keymapp def)
+                    (or all
+                        ;; event 27 is escape, so this will pick up meta
+                        ;; bindings and hopefully not too much more
+                        (and (numberp ev) (= ev 27))))
                (setq bindings
                      (append bindings
                              (which-key--get-keymap-bindings def t key)))
-             (cl-pushnew
-              (cons key-desc
-                    (cond
-                     ((keymapp def) "Prefix Command")
-                     ((symbolp def) (copy-sequence (symbol-name def)))
-                     ((eq 'lambda (car-safe def)) "lambda")
-                     ((eq 'menu-item (car-safe def)) "menu-item")
-                     (t (format "%s" def))))
-              bindings :test (lambda (a b) (string= (car a) (car b))))))))
+             (when def
+               (cl-pushnew
+                (cons key-desc
+                      (cond
+                       ((keymapp def) "Prefix Command")
+                       ((symbolp def) (copy-sequence (symbol-name def)))
+                       ((eq 'lambda (car-safe def)) "lambda")
+                       ((eq 'menu-item (car-safe def)) "menu-item")
+                       ((stringp def) def)
+                       (t "unknown")))
+                bindings :test (lambda (a b) (string= (car a) (car b)))))))))
      keymap)
     bindings))